<?php
	
	header("Content-Type: text/html;charset=utf-8");

	$servername = "localhost";
	$username = "root";
	$password = "456789";
	$dbname = "mysqlstudy";

	$conn = new mysqli($servername,$username,$password,$dbname);
	if($conn -> connect_error){
		die("连接失败:" . $conn -> connect_error);
	}
	mysqli_query($conn, "set names utf8");


	$userSql = "SELECT uid,name FROM user"; 
	$useResult = $conn -> query($userSql);
	$userObj = $useResult -> fetch_all(MYSQLI_ASSOC);

	$roleSql = "SELECT * FROM role";
	$roleResult = $conn -> query($roleSql);
	$roleObj = $roleResult -> fetch_all(MYSQLI_ASSOC);

	$allResult = array("user"=>$userObj,"role"=>$roleObj);

	echo json_encode($allResult);

?>